import { AntiGravity, transformParams } from '@/utils/utils';
import request from '@/utils/request';
import { sm2 } from 'sm-crypto';

const pubkey = '039e4e357cf4fd771334f7bca8e152305b83a864c8862302283fd1a39519fdd8a2'; // 加

export async function getTradeData(params) {
  return request({
    url: `/api/server-carbon/trading/queryCarbonTradingScaleStatistics`,
    // data: '04' + sm2.doEncrypt(JSON.stringify(params), pubkey, 1),
    method: 'POST',
    data: JSON.stringify(params),
    headers: {
      ...AntiGravity(),
    },
  });
}

export async function getTrendData(params) {
  return request({
    url: `/api/server-carbon/trend/queryCarbonPriceTrendStatistics`,
    method: 'POST',
    data: JSON.stringify(params),
    headers: {
      ...AntiGravity(),
    },
  });
}

export async function getDictionariesList(params) {
  return request({
    url: `/api/server-carbon/reduction/queryDictionariesList`,
    method: 'POST',
    data: JSON.stringify(params),
    headers: {
      ...AntiGravity(),
    },
  });
}

export async function getReductionList(params) {
  return request({
    url: `/api/server-carbon/reduction/list?${transformParams(
      params,
    )}`,
    method: 'GET',
    headers: {
      ...AntiGravity(),
    },
  });
}

export async function downloadReductionTemplate(params) {
  return request({
    url: `/api/server-carbon/reduction/downloadReductionTemplate`,
    method: 'POST',
    data: JSON.stringify(params),
    responseType: 'blob',
    headers: {
      ...AntiGravity(),
    },
  });
}

export async function getCompositionList(params) {
  return request({
    url: `/api/server-carbon/composition/list?${transformParams(
      params,
    )}`,
    method: 'GET',
    headers: {
      ...AntiGravity(),
    },
  });
}

export async function getAssetsStatisticsData(params) {
  return request({
    url: `/api/server-carbon/composition/queryCarbonAssetsStatistics`,
    method: 'POST',
    data: JSON.stringify(params),
    headers: {
      ...AntiGravity(),
    },
  });
}

export async function getAnnualInformation(params) {
  return request({
    url: `/api/server-carbon/analysis/queryAnnualInformation`,
    method: 'POST',
    data: JSON.stringify(params),
    headers: {
      ...AntiGravity(),
    },
  });
}

export async function getAnalysisList(params) {
  return request({
    url: `/api/server-carbon/analysis/list?${transformParams(
      params,
    )}`,
    method: 'GET',
    headers: {
      ...AntiGravity(),
    },
  });
}

export async function getFinanceScaleStatistics(params) {
  return request({
    url: `/api/server-carbon/finance/queryCarbonFinanceScaleStatistics`,
    method: 'POST',
    data: JSON.stringify(params),
    headers: {
      ...AntiGravity(),
    },
  });
}

export async function getFirmList(params) {
  return request({
    url: `/api/server-carbon/firm/list?${transformParams(
      params,
    )}`,
    method: 'GET',
    headers: {
      ...AntiGravity(),
    },
  });
}

export async function getGreenAptituAssessList(params) {
  return request({
    url: `/api/server-carbon/aptitu/queryGreenAptituAssessList`,
    method: 'POST',
    data: JSON.stringify(params),
    headers: {
      ...AntiGravity(),
    },
  });
}

export async function getCreditDictionariesList(params) {
  return request({
    url: `/api/server-carbon/credit/queryDynamicDictionary?${transformParams(
      params,
    )}`,
    method: 'GET',
    headers: {
      ...AntiGravity(),
    },
  });
}

export async function getCreditList(params) {
  return request({
    url: `/api/server-carbon/credit/list?${transformParams(
      params,
    )}`,
    method: 'GET',
    headers: {
      ...AntiGravity(),
    },
  });
}

export async function getCarbonTradingScaleTrend(params) {
  return request({
    url: `/api/server-carbon/scaleTrend/queryCarbonPriceScaleTrendStatistics?${transformParams(
      params,
    )}`,
    method: 'POST',
    headers: {
      ...AntiGravity(),
    },
  });
}